package lmscript.postscript.syntax;

import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Map;

public class PSDictionary extends PSComposite {

	private Dictionary<PSObject, PSObject> dictionary;
	private String dictName;
	
	public PSDictionary() {
		super("dictionary", LITERAL);
		this.dictionary = new Hashtable<PSObject, PSObject>();
	}
	
	public PSDictionary(int initialCapacity) {
		super("dictionary", LITERAL);
		this.dictionary = new Hashtable<PSObject, PSObject>(initialCapacity);
	}
	
	public PSDictionary(String dictName) {
		this();
		this.dictName = dictName;
	}

	public void put(PSObject key, PSObject value) {
		this.dictionary.put(key, value);
	}

	public void put(String key, PSObject value) {
		this.put(new PSName(key), value);
	}

	public PSObject get(String key) {
		return this.dictionary.get(new PSName(key));
	}

	public PSObject get(PSObject key) {
		return this.dictionary.get(key);
	}

	public int size() {
		return this.dictionary.size();
	}

	public boolean isEmpty() {
		return this.dictionary.isEmpty();
	}

	public boolean containsKey(PSObject key) {
		return this.dictionary.get(key) != null;
	}

	public boolean containsKey(String key) {
		return this.dictionary.get(new PSName(key)) != null;
	}

	public PSObject remove(PSObject key) {
		return this.dictionary.remove(key);
	}

	public PSObject remove(String key) {
		return this.dictionary.remove(new PSName(key));
	}

	public void putAll(Map<PSObject, PSObject> m) {
		this.putAll(m);
	}

	public void clear() {
		this.clear();
	}

	public Enumeration<PSObject> keys() {
		return this.dictionary.keys();
	}

	public Enumeration<PSObject> elements() {
		return this.dictionary.elements();
	}
	
	public String getDictName() {
		return this.dictName;
	}
}
